package com.jeesite.modules.common;


/**
 * 系统错误信息枚举类
 */
public enum ErrorEnum {
	SYSTEM_ERROR("100","系统错误");


	private final String errorCode;
	private final String errorMsg;
	
	ErrorEnum(String errorCode, String errorMsg){
		this.errorCode=errorCode;
		this.errorMsg=errorMsg;
	}
	
	public BusinessException getException(){
		return getBusinessException(errorMsg);
	}
	
	public BusinessException getBusinessException(String msg){
		return new BusinessException(errorCode,  msg);
	}
	
	public String getErrorCode() {
		return errorCode;
	}
	 
	public String getErrorMsg() {
		return errorMsg;
	}
	
	public static ErrorEnum findByCode(String code){
		for (ErrorEnum value : ErrorEnum.values()) {
			if(value.errorCode.equalsIgnoreCase(code)){
				return value;
			}
		}
		return null;
	}
}
